package org.sbbs.app.demo.schedule;

import org.springframework.core.task.TaskExecutor;

public class DemoScheduleTaskExecutor {
    private class MessagePrinterTask
        implements Runnable {
        private String message;

        public MessagePrinterTask( String message ) {
            this.message = message;
        }

        public void run() {
            System.out.println( message );
        }
    }

    private TaskExecutor taskExecutor;

    public DemoScheduleTaskExecutor( TaskExecutor taskExecutor ) {
        this.taskExecutor = taskExecutor;
    }

    public void printMessages() {
        for ( int i = 0; i < 25; i++ ) {
            taskExecutor.execute( new MessagePrinterTask( "Message" + i ) );
        }
    }
}
